//
//  MANoteManageCell.m
//  meiang_edu
//
//  Created by 栋 on 2018/12/31.
//  Copyright © 2018年 com.meiang.meiang_edu. All rights reserved.
//

#import "MANoteManageCell.h"

@interface MANoteManageCell()

/**
 作业标题
 */
@property (weak, nonatomic) IBOutlet UILabel *lblTitle;

/**
 作业内容
 */
@property (weak, nonatomic) IBOutlet UILabel *lblDes;

/**
 时间
 */
@property (weak, nonatomic) IBOutlet UILabel *lblDate;

/**
 作业简图
 */
@property (weak, nonatomic) IBOutlet UIImageView *imageV;

/**
 lblTitle 右侧约束
 */
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *layoutLblTitleRight;

/**
 lblDes 右侧约束
 */
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *layoutLblDesRight;

/**
 当前行号
 */
@property (nonatomic ,strong) NSIndexPath * indexPath;

@property (nonatomic ,strong) MANoteManageModel * model;

@end

@implementation MANoteManageCell

- (void)setDataWithModel:(MANoteManageModel*)model indexPath:(NSIndexPath *)indexPath{
    _model = model;
    _indexPath = indexPath;
    self.lblTitle.text = model.message_title;
    self.lblDes.text = model.message_content;
    self.lblDate.text = model.send_time;
    if (model.message_image_count.integerValue>0) {
        self.layoutLblDesRight.constant = 154.5;
        self.layoutLblTitleRight.constant = 139.5;
        self.imageV.hidden = NO;
        NSArray * message_images = [model.message_images componentsSeparatedByString:@","];
         [self.imageV ma_setImageWithURL:message_images.firstObject placeholderImage:[UIImage imageNamed:@"picture_logo"]];
    }else{
        self.layoutLblDesRight.constant = 15;
        self.layoutLblTitleRight.constant = 15;
        self.imageV.hidden = YES;
    }
   
}

- (void)awakeFromNib{
    [super awakeFromNib];
    //添加长按手势
    UILongPressGestureRecognizer * longPressGesture =[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPress:)];
    
    longPressGesture.minimumPressDuration=1.5f;//设置长按 时间
    [self addGestureRecognizer:longPressGesture];
}

-(void)longPress:(UILongPressGestureRecognizer *)longRecognizer{
    if (longRecognizer.state==UIGestureRecognizerStateBegan) {
        if ([self.delegate respondsToSelector:@selector(noteManageCellDidLongPress:model:)]) {
            [self.delegate noteManageCellDidLongPress:self model:_model];
        }
    }
}

@end
